﻿' ******************************************************************************
' ** 
' **  Yahoo Finance Managed
' **  Written by Marius Häusler 2010
' **  It would be pleasant, if you contact me when you are using this code.
' **  Contact: YahooFinanceManaged@gmail.com
' **  Project Home: http://code.google.com/p/yahoo-finance-managed/
' **  
' ******************************************************************************
' **  
' **  Copyright 2010 Marius Häusler
' **  
' **  Licensed under the Apache License, Version 2.0 (the "License");
' **  you may not use this file except in compliance with the License.
' **  You may obtain a copy of the License at
' **  
' **    http://www.apache.org/licenses/LICENSE-2.0
' **  
' **  Unless required by applicable law or agreed to in writing, software
' **  distributed under the License is distributed on an "AS IS" BASIS,
' **  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
' **  See the License for the specific language governing permissions and
' **  limitations under the License.
' ** 
' ******************************************************************************


Namespace Finance

    ''' <summary>
    ''' Stores informations of quote options. Serializable. 
    ''' </summary>
    ''' <remarks></remarks>
    <Serializable()> _
    Public Class QuoteOptionData
        Private mSymbol As String = String.Empty
        Private mType As QuoteOptionType = QuoteOptionType.CallIndicator
        Private mValues(4) As Double
        Private mValuesInt(1) As Integer

        ''' <summary>
        ''' The basic parts of new option symbol are: Root symbol + Expiration Year(yy)+ Expiration Month(mm)+ Expiration Day(dd) + Call/Put Indicator (C or P) + Strike price
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Symbol() As String
            Get
                Return mSymbol
            End Get
            Set(ByVal value As String)
                mSymbol = value
            End Set
        End Property
        ''' <summary>
        ''' Call/Put Indicator
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Type() As QuoteOptionType
            Get
                Return mType
            End Get
            Set(ByVal value As QuoteOptionType)
                mType = value
            End Set
        End Property
        ''' <summary>
        '''  The stated price per share for which underlying stock can be purchased (in the case of a call) or sold (in the case of a put) by the option holder upon exercise of the option contract.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property StrikePrice() As Double
            Get
                Return mValues(0)
            End Get
            Set(ByVal value As Double)
                mValues(0) = value
            End Set
        End Property
        ''' <summary>
        ''' The price of the last trade made for option contract.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property LastPrice() As Double
            Get
                Return mValues(1)
            End Get
            Set(ByVal value As Double)
                mValues(1) = value
            End Set
        End Property
        ''' <summary>
        ''' The change in price for the day. This is the difference between the last trade and the previous day's closing price (Prev Close). The change is reported as "0" if the option hasn't traded today.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Change() As Double
            Get
                Return mValues(2)
            End Get
            Set(ByVal value As Double)
                mValues(2) = value
            End Set
        End Property
        ''' <summary>
        ''' The Bid price is the price you get if you were to write (sell) an option.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Bid() As Double
            Get
                Return mValues(3)
            End Get
            Set(ByVal value As Double)
                mValues(3) = value
            End Set
        End Property
        ''' <summary>
        ''' The Ask price is the price you have to pay to purchase an option.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Ask() As Double
            Get
                Return mValues(4)
            End Get
            Set(ByVal value As Double)
                mValues(4) = value
            End Set
        End Property
        ''' <summary>
        ''' The volume indicates the number of option contracts that have traded for the current day.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Volume() As Integer
            Get
                Return mValuesInt(0)
            End Get
            Set(ByVal value As Integer)
                mValuesInt(0) = value
            End Set
        End Property
        ''' <summary>
        ''' The total number of derivative contracts traded that have not yet been liquidated either by an offsetting derivative transaction or by delivery.
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property OpenInterest() As Integer
            Get
                Return mValuesInt(1)
            End Get
            Set(ByVal value As Integer)
                mValuesInt(1) = value
            End Set
        End Property

        ''' <summary>
        ''' Default constructor
        ''' </summary>
        ''' <remarks></remarks>
        Public Sub New()
        End Sub
        Friend Sub New(ByVal symb As String, ByVal typ As QuoteOptionType, ByVal strike As Double, ByVal last As Double, ByVal cng As Double, ByVal b As Double, ByVal a As Double, ByVal vol As Integer, ByVal interest As Integer)
            Me.Symbol = symb
            Me.Type = typ
            Me.StrikePrice = strike
            Me.LastPrice = last
            Me.Change = cng
            Me.Bid = b
            Me.Ask = a
            Me.Volume = vol
            Me.OpenInterest = interest
        End Sub

    End Class

End Namespace